
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import electron from 'vite-plugin-electron'

// https://vitejs.dev/config/
export default defineConfig({

  plugins: [
    vue(),
    electron({
      // 主进程入口文件
      entry: './electron/entry.js'
    }),
    // ...
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'),      // 将图片引入的./  ../  统一用@代替
    }
  },
  //本地运行配置，以及反向代理配置
  server: {
    // port: "8888",//端口
    host: "127.0.0.1",//ip地址例如192.168.1.177
    open: true,//服务启动时自动在浏览器中打开应用
    // 反向代理配置
    proxy: { //配置多个代理
      '/api': {
        target: "http://47.122.93.94:3333",
        changeOrigin: true, //设置访问目标地址允许跨域
        rewrite: (p) => p.replace(/^\/api/, '')
      },

    }
  }


})
